草庐IT

objective-c - Windows 和 objective-c

全部标签

ruby-on-rails - 主要 :Object 的 RSpec 3.1 未定义方法 `feature'

我正在经历相当痛苦的RSpec3.1升级。我有几个在RSpec2.99中工作的功能规范,它们提高了:undefinedmethod`feature'formain:Object我注意到我必须在我的其他规范中使用RSpec.describe,因为它们不再附加到主要对象。等效的功能调用是什么?在我的功能中我需要'rails_helper'require'rails_helper'feature'FacebookAuthentiation'do...endspec/rails_helper.rb#Thisfileiscopiedtospec/whenyourun'railsgenerater

ruby - Ruby 中 Kernel#yield_self、yield(self)、Kernel#then 和 Object#tap 之间的区别?

Ruby2.5引入了#yield_self方法。Ruby2.6引入了#then方法。yield_self、yield(self)、then和现有的Object#tap有什么区别方法? 最佳答案 tap之间的区别和yield_self在这两种方法返回的内容中。Object#tap将self生成到block,然后返回self。Kernel#yield_self将自身交给block,然后返回block的结果。这里有一些例子,说明每个例子都有用:点击替换方法末尾对result行的需要:defmy_methodresult=get_some_

ruby - RSpec - as_null_object?

我不清楚as_null_object的目的是什么是什么情况下你会使用它?根据关于Relish的文档:Usetheas_null_objectmethodtoignoreanymessagesthataren'texplicitlysetasstubsormessageexpectations.没有向我注册。 最佳答案 当您不关心对象的行为或交互,并且不想显式地stub所有需要的东西时,使用空对象。使用空对象上的任何参数调用任何方法都不会导致NoMethodError或ArgumentError。另请参阅NullObjectPatte

ruby-on-rails - 无方法错误 : undefined method `on' for main:Object

当我尝试bundleexeccapproductiondeploy--trace时,我收到一条错误消息:deploy@h2540559:/www/apps/foodsoft$bundleexeccapproductiondeploy--trace**Invokeproduction(first_time)**Executeproduction**Invokeload:defaults(first_time)**Executeload:defaults**Invokervm:hook(first_time)**Executervm:hookcapaborted!NoMethodError

ruby-on-rails - 无法在 Windows 7 上安装 MySQL2 gem

我在安装时收到以下错误消息,如果我需要发布更多详细信息,请告诉我。我按照以下位置的说明操作:https://github.com/oneclick/rubyinstaller/wiki/Development-Kit我正在使用ruby​​1.9.2p136(2010-12-25)[i386-mingw32]。这是我得到的:E:\work_desk\trunk>geminstallmysql2-v0.2.4TemporarilyenhancingPATHtoincludeDevKit...Buildingnativeextensions.Thiscouldtakeawhile...ERR

ruby - 在 Windows 上的 Ruby 1.9.1 上安装 Hpricot

我正在尝试使用以下命令安装hpricot:>geminstallhpricot-v0.8.2Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallinghpricot:ERROR:Failedtobuildgemnativeextension.C:/Ruby19/bin/ruby.exeextconf.rbcheckingforstdio.h...*extconf.rbfailed*CouldnotcreateMakefileduetosomereason,probablylackofnecessarylibr

ruby-on-rails - 错误 "' Validate_default_type !': An option' s default must match its type (ArgumentError)"when running Ruby on Rails generate on Windows

我正在关注thistutorial并且刚刚开始。我已经使用geminstallrails安装了RubyonRails,并使用railsnewblog创建了一个博客。教程现在说我需要运行railsgeneratecontrollerWelcomeindex,但是当我这样做时,我得到了这个错误:C:/Ruby22/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/option.rb:130:in`validate_default_type!':Anoption'sdefaultmustmatchitstype.(ArgumentErr

Ruby:使用 Object.send 分配变量

有什么办法可以做这样的事情吗?a=Struct.new(:c).new(1)b=Struct.new(:c).new(2)a.send(:c)=>1b.send(:c)=>2a.send(:c)=b.send(:c)最后一行导致错误:syntaxerror,unexpected'=',expecting$enda.send(:c)=b.send(:c)^ 最佳答案 a.send(:c=,b.send(:c))foo.bar=baz不是调用方法bar后跟赋值-它是调用方法bar=。因此,您需要告诉send调用该方法。

ruby-on-rails - rails : Copying attributes from an object to another using the "attributes" method

让模型Quote具有属性[price,description]让模型Invoice有属性[price,description,priority]让invoice模型Invoice中的对象具有属性{price:10,description:'lamp',priority:10}invoice={price:10,description:'lamp',priority:10}假设我想将invoice属性复制到新的quote。quote=Quote.new(invoice.attributes)这会引发一个错误,即priority在模型Quote中不存在。如何将invoice属性复制到新的q

ruby-on-rails - Ruby 1.9.2 如何在 Windows 上安装 RMagick?

我目前正在升级一个旧的Rails应用程序以使用Rails3和Ruby1.9.2,而RMagick是我需要安装的最后一个gem。然而,似乎没有任何适用于Windows的1.9.2下载,标准的gem安装RMagick也不起作用。有人能为我指出正确的方向来安装这个gem吗? 最佳答案 我刚刚使用Rubyv1.9.x在Windows上成功安装了RMagick2.13.1!在我忘记之前,让我把程序说出来。安装开发工具包:https://github.com/oneclick/rubyinstaller/wiki/Development-Kit